package ca.ets.utilities;

import java.io.Serializable;


public class InscriptionEvent extends EventAbs implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private int availablePlace =0;
	private int name;
	private boolean availability = false;
	
	public InscriptionEvent(String name, Adresse adr, String phone, String stDate, String enDate, int noID){
		super.setNom(name);
		super.setAdresse(adr);
		super.setTelephone(phone);
		super.setStartDate(stDate);
		super.setEndDate(enDate);
		super.setNoID(noID);
		
	}

	/**
	 * @return the availablePlace
	 */
	public int getAvailablePlace() {
		return availablePlace;
	}

	/**
	 * @param availablePlace the availablePlace to set
	 */
	public void setAvailablePlace(int availablePlace) {
		this.availablePlace = availablePlace;
	}

	/**
	 * @return the name
	 */
	public int getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(int name) {
		this.name = name;
	}
	
	
	public ConcreteEvent getEvent(){
		ConcreteEvent e =null;
		if(isAvailability()== true){
			e = new ConcreteEvent();
			e.setAdresse(this.getAdresse());
			e.setEndDate(this.getEndDate());
			e.setStartDate(this.getStartDate());
			e.setNom(this.getNom());
			e.setNoID(this.getNoID());
			e.setTelephone(this.getTelephone());		
			
			this.availablePlace = availablePlace - 1;
			setAvailability();
		}
		return e;
		
	}
	
	public void setAvailability(){
		if(this.availablePlace > 0){
			availability = true;
		}
		else{
			availablePlace =0;
			availability = false;
		}
	}

	/**
	 * @return the availability
	 */
	public boolean isAvailability() {
		return availability;
	}
	
	
	

}
